import request from '@/utils/request'

//1. 查询品牌列表
//请求参数类型限制
export interface reqTrademarkParamsType {
    page:number;
    limit:number;
}

//返回值类型限制   
// records: reqTrademarkReturnRecordsType;把这个里面很多东西分解出来用个空数组接数据 
//然后再使用他里面并且分别定义一个id     扩展reqAddTradeParamsType这个是新增 因为你要获取最新的
export interface reqTrademarkReturnItemType extends reqAddTradeParamsType {
    id: number;
  }
  export type reqTrademarkReturnRecordsType = reqTrademarkReturnItemType[];

  export interface reqTrademarkReturnType {
    records: reqTrademarkReturnRecordsType;
    total: number;
    size: number;
    current: number;
    searchCount: boolean;
    pages: number;
  }
  export const requestTrademarkList = ({
    page,
    limit,
  }: reqTrademarkParamsType) => {
    return request.get<any, reqTrademarkReturnType>(
      `/admin/product/baseTrademark/${page}/${limit}`
    );
  };

  //2. 修改品牌  tradmark第一个是接收定义类型 第二个是传值
  export const requestUpdateTrademark = (
    trademark: reqTrademarkReturnItemType
  ) => {
    return request.put<any, null>(
      `/admin/product/baseTrademark/update`,
      trademark
    );
  };

  //3.删除品牌
  export const requestDeleteTrademark = (id: number) => {
  return request.delete<any, null>(`/admin/product/baseTrademark/remove/${id}`);
};

 //4. 新增品牌
 export interface reqAddTradeParamsType {
    tmName: string;
    logoUrl: string;
  }
  export const requestAddTrademark = (trademark: reqAddTradeParamsType) => {
    return request.post<any, null>(
      `/admin/product/baseTrademark/save`,
      trademark
    );
  };
  


